<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>
        <ui:composition template="./template/News_Template.xhtml">
            <ui:define name="content">
                <h:form>
                    <h:outputText value="Lấy một tin :"/>
                    <h:inputText value="#{getOneNews.url}"/>
                    <h:commandButton value="Lấy tin" action="#{getOneNews.doGetNews}">
                        <f:ajax execute="@form" render="news" onevent="showWorkingIndicator"/>
                    </h:commandButton>
                    <hr/>
                    <h:panelGroup id="news" rendered="#{getOneNews.avable}">

                        <h:outputText value="#{getOneNews.newsItem.title}" style="font-weight: bold"/>
                        <br/>
                        <br/>
                        <h:outputText value="#{getOneNews.newsItem.subContent}" style="font-weight: normal;color: darkgrey"/>
                        <br/>
                        <br/>
                        <h:outputLabel value=" #{getOneNews.newsItem.mainContent}" escape="false"/>
                        <h:commandButton id="insert" style="float: right"
                                         value="Lấy tin vào database !" action="#{getOneNews.insertNewsToDB}">
                            <f:ajax render="hihi" execute="@form" onevent="showWorkingIndicator"/>
                        </h:commandButton>
                        <h:panelGroup id="hihi">
                            <h:outputText rendered="#{getOneNews.flag}" value="#{getOneNews.message}" style="font-weight: bold"/><br/>
                        </h:panelGroup>
                        <span id="workingIndicator"
                                              style="display: none;">
                            <h:graphicImage library="images" name="ajax-loader.gif"/>
                            <br/>
                            <h:outputText value="Đang tải dữ liệu từ máy chủ..."/>
                        </span>
                    </h:panelGroup>
                </h:form>
            </ui:define>
        </ui:composition>
    </body>
</html>
